package com.xnfh.equipment.viewmodel

import android.view.View.BaseSavedState
import com.xnfh.common.bean.EquipmentGl
import com.xnfh.framework.base.BaseViewModel
import com.xnfh.framework.bean.RespStateData
import org.json.JSONObject

/**
 * @Description:
 * @Author: ziheng
 * @CreateDate: 2023/12/27 18:46
 * @UpdateUser: ziheng
 * @UpdateDate: 2023/12/27 18:46
 * @UpdateRemark: 更新说明
 */
class InternetThingsViewModel : BaseViewModel() {
    private val internetThingsViewModelRes = InternetThingsViewModelRes()
    val weatherList = RespStateData<EquipmentGl>()

    /**
     * 获取气象站数据
     */
    fun requestWeatherList(page: Int, keywords: String? = null) = launch {
        val jsonObject = JSONObject()
        jsonObject.put("current", page)
        jsonObject.put("size", 20)
        keywords?.let {
            jsonObject.put("wsName", keywords)
        }
        internetThingsViewModelRes.requestWeatherList(
            creatRequestBody(jsonObject.toString()),
            weatherList
        )
    }
}